import { Router } from "express";
import { AuthMiddleware } from "../../core/middleware/auth.js";
import { FileController } from "./controller.js";
import { errorHandler } from "../../core/middleware/errorHandler.js";

import { API_URLS } from "../../config/api-urls.js";

const router = Router();


// 文件列表
router.get(
  API_URLS.GET_FILES_LIST,
  AuthMiddleware.authenticate(process.env.JWT_SECRET),
  FileController.getFilesList
);


// 删除文件
router.delete(
  API_URLS.UPLOAD_DELETE,
  AuthMiddleware.authenticate(process.env.JWT_SECRET),
  FileController.deleteFile
);



// 检测文件是否存在
router.get(
  API_URLS.UPLOAD_VERIFY,  
  AuthMiddleware.authenticate(process.env.JWT_SECRET),
  FileController.checkFileExists
);

// 错误处理
router.use(errorHandler);

export default router;
